package com.flute.haflute.net;

import gnu.cajo.invoke.Remote;

import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

import com.flute.haflute.common.ClusterContext;

public class RMILocalClient {
	private static String rmiURI = "//localhost:" + (ClusterContext.getRMIPort() - 1) + "/";

	public static Object getServiceObject(String serviceName) throws RemoteException, MalformedURLException, NotBoundException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException{
		return Remote.getItem(rmiURI + serviceName);
	}
	
	public static Object invoke(Object serviceObj, String methodName, Object param) throws Exception {
		return Remote.invoke(serviceObj, methodName, param);	
	}

}
